int cmp(int* x, int* y)
{
    return *y - *x;
}

int dominantIndex(int* nums, int numsSize) {
    int index = 0, max = nums[0];
    for (int i = 1; i < numsSize; i++)
    {
        if (max < nums[i])
        {
            max = nums[i];
            index = i;
        }
    }
    qsort(nums, numsSize, sizeof(int), cmp);
    if (nums[0] >= 2 * nums[1])
        return index;
    return -1;
}